//
//  YMClassifyTabView.swift
//  YMSwiftUI
//
//  Created by anscen on 2022/3/18.
//

import SwiftUI
import PagerTabStripView
import Hue
import Parchment
struct YMClassifyTabView: View {

    private var listData :[String] = ["male","female","press","picture"]
    private var config: PagingOptions =  PagingOptions.init()
    @State private var itemData : [PagingIndexItem] = [PagingIndexItem(index: 0, title: "男生"),PagingIndexItem(index: 1, title: "女生"),PagingIndexItem(index: 2, title: "出版社"),PagingIndexItem(index: 3, title: "其他")]
    @State private var selectedTab = 0
    init() {
        loadData()
    }
    var body: some View {
        GeometryReader { root in
            HStack {
                PageView(options: self.config, items: itemData, selectedIndex: $selectedTab) {objc in
                    YMClassifyView(titleName: self.listData[objc.index])
                }.onAppear {
                    debugPrint(root.size.width)
                }
            }.onAppear {
                debugPrint("YMClassifyTabView")
                debugPrint(root.size.width)
            }
        }
    }
    mutating func loadData(){
        self.config.font = UIFont.boldSystemFont(ofSize: 18)
        self.config.selectedFont = UIFont.boldSystemFont(ofSize: 18)
        self.config.menuItemSpacing = 0
        self.config.indicatorColor = UIColor(AppColor)
        self.config.menuHorizontalAlignment = .left
        self.config.menuInteraction = .scrolling
        self.config.menuItemSize = PagingMenuItemSize.selfSizing(estimatedWidth: 80, height: 44)
        self.config.menuInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
        self.config.menuItemLabelSpacing = 20
        self.config.indicatorOptions = PagingIndicatorOptions.visible(height: 3, zIndex: 0, spacing: UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20), insets: UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20))
    }
}
